<!DOCTYPE html>
<html lang="zh">
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
		<title>首页index</title>
		<link rel="icon" href="favicon.ico" type="image/ico">
		<meta name="author" content="yinqi">
		<link href="css/bootstrap.min.css" rel="stylesheet">
		<link href="css/materialdesignicons.min.css" rel="stylesheet">
		<link href="css/style.css" rel="stylesheet">
		<!--对话框-->
		<link rel="stylesheet" href="js/jconfirm/jquery-confirm.min.css">
	</head>

	<body data-logobg="color_8" data-sidebarbg="color_8">
		<div class="layout-web">
			<div class="layout-container">
				<!--左侧导航-->
				<aside class="layout-sidebar">

					<!-- logo -->
					<div id="logo" class="sidebar-header">
						<a href="backindex.html" target="menuFrame"><img src="images/logo.png" width="60%" /></a>
					</div>
					<div class="layout-sidebar-scroll">

						<nav class="sidebar-main">
							<ul class="nav nav-drawer">
								<li class="nav-item" onclick="changetop(this)"> <a href="backindex.html"
										target="menuFrame"><i class="mdi mdi-home"></i> 首页</a>
								</li>
								<li class="nav-item nav-item-has-subnav">
									<a href="javascript:void(0)"><i class="mdi mdi-palette"></i> 客户信息</a>
									<ul class="nav nav-subnav">
										<li onclick="changetop(this)"> <a href="addclient.html"
												target="menuFrame">新增</a> </li>
										<li id="searchall" onclick="changetop(this)"> <a href="searchall.html"
												target="menuFrame">客户名单（管理者可用）</a> </li>
									</ul>
								</li>
								<li class="nav-item nav-item-has-subnav">
									<a href="javascript:void(0)"><i class="mdi mdi-format-align-justify"></i> 客户详情</a>
									<ul class="nav nav-subnav">
										<li onclick="changetop(this)"> <a href="myclient.html"
												target="menuFrame">我的客户</a> </li>
										<li onclick="changetop(this)"> <a href="grabclient.html"
												target="menuFrame">公开抢单</a> </li>
									</ul>
								</li>
								<li class="nav-item" onclick="changetop(this)"> <a href="questionpage.html"
										target="menuFrame"><i class="mdi mdi-palette"></i> 问答知识库</a>
								</li>
							</ul>
						</nav>
						<div class="sidebar-footer">
							<p class="copyright">&copy; 2022 <a href="http://www.packingboss.com.cn/">箱博士</a></p>
						</div>
					</div>

				</aside>
				<!--End 左侧导航-->

				<!--头部信息-->
				<header class="layout-header">

					<nav class="navbar navbar-default">
						<div class="topbar">

							<div class="topbar-left">
								<div class="aside-toggler">
									<span class="toggler-bar"></span>
									<span class="toggler-bar"></span>
									<span class="toggler-bar"></span>
								</div>
								<span class="navbar-page-title" id="toptext"> 首页 </span>
							</div>

							<ul class="topbar-right">
								<li class="dropdown dropdown-profile">
									<a href="javascript:void(0)" data-toggle="dropdown">
										<img class="img-avatar img-avatar-48 m-r-10" src="images/usericon.png"
											alt="用户名" />
										<span id="username"> 用户名</span><span class="caret"></span>
									</a>
									<ul class="dropdown-menu dropdown-menu-right">
										<li> <a href="profile_edit.html" target="menuFrame"><i
													class="mdi mdi-account"></i> 个人信息</a> </li>
										<li> <a href="profile_edit_password.html" target="menuFrame"><i
													class="mdi mdi-lock-outline"></i> 修改密码</a>
										</li>
										<li class="divider"></li>
										<li> <a href="javascript:void(0);" onclick="logout()"><i
													class="mdi mdi-logout-variant"></i> 退出登录</a>
										</li>
									</ul>
								</li>
							</ul>

						</div>
					</nav>
				</header>
				<main class="layout-content">
					<div style="margin-top: 10px;">
						<!--页面主要内容-->
						<iframe src="backindex.html" id="menuFrame" name="menuFrame" width="100%" height="800px"
							frameborder="0"></iframe>
						<!--End 页面主要内容-->
					</div>
				</main>
			</div>
		</div>



		<script type="text/javascript" src="js/jquery.min.js"></script>
		<script type="text/javascript" src="js/bootstrap.min.js"></script>
		<script type="text/javascript" src="js/perfect-scrollbar.min.js"></script>
		<script type="text/javascript" src="js/main.js"></script>

		<!--图表插件-->
		<link rel="stylesheet" type="text/css" href="layui/layui/css/layui.css">
		<script type="text/javascript" src="layui/layui/layui.js"></script>
		<script type="text/javascript" src="js/Chart.js"></script>
		<script src="js/jconfirm/jquery-confirm.min.js"></script>
		<script src="https://cdn.jsdelivr.net/npm/js-cookie@2/src/js.cookie.min.js"></script>
		<script src="js/ServerUrl.js"></script>
		<script type="text/javascript">
			// 由操作员身份决定菜单功能
			$(function() {
				var identity = Cookies.get('identity');
				if (identity == "normal") {
					$('#searchall').css('display', 'none');
					$('#editclient').css('display', 'none');
				} else if (identity == "admin") {
					$('#searchall').css('display', 'block');
					$('#editclient').css('display', 'block');
				}
			});
			// 每次刷新主页面时更新一下 此业务员的最新时间
			$(function() {
				// 	console.log(storage.getItem("username"));
				if (Cookies.get('islogin') == "true") {
					$("#username").text(Cookies.get('username'));
					var id = Cookies.get('id');
					$.ajax({
						//几个参数需要注意一下
						type: "post", //方法类型
						dataType: "json", //预期服务器返回的数据类型
						url: serverUrl + "/updateUsertime",
						data: {
							"id": id
						},
						success: function(result) {
							if (Cookies.get('islogin') == "true" && Cookies.get('expires') == "3") {
								Cookies.set('latesttime', result.latesttime, {
									expires: 3
								});
								Cookies.set('status', result.status, {
									expires: 3
								});
							} else if (Cookies.get('islogin') == "true" && Cookies.get('expires') ==
								"temp") {
								Cookies.set('latesttime', result.latesttime);
								Cookies.set('status', result.status);
							}
							if (result.identity == "normal" && result.status == "timeout") {
								preventEnter('由于您超过三天未登录《箱博士》系统，无法再次登录，请联系管理员解决');
							}
						},
						error: function() {
							layer.msg('更新时间时异常');
						}
					});
				} else {
					preventEnter('当前未登录《箱博士》管理系统，无法浏览具体内容，请登录后再试');
				}
			});

			function preventEnter(message) {
				$.confirm({
					title: '错误提示',
					content: message,
					type: 'red',
					typeAnimated: true,
					buttons: {
						tryAgain: {
							text: '确定',
							btnClass: 'btn-red',
							action: function() {
								window.location.href = 'pages_login.html';
							}
						},
						close: {
							text: '关闭',
							action: function() {
								window.location.href = 'pages_login.html';
							}
						}
					}
				});
			}
		</script>
		<script type="text/javascript">
			function logout() {
				Cookies.set('islogin', "false", {
					expires: 0
				});
				Cookies.set('username', null, {
					expires: 0
				});
				Cookies.set('expires', null, {
					expires: 0
				});
				Cookies.set('password', null, {
					expires: 0
				});
				Cookies.set('phone', null, {
					expires: 0
				});
				Cookies.set('identity', null, {
					expires: 0
				});
				window.location.href = 'pages_login.html';
			}
			$(document).ready(function(e) {
				var $dashChartBarsCnt = jQuery('.js-chartjs-bars')[0].getContext('2d'),
					$dashChartLinesCnt = jQuery('.js-chartjs-lines')[0].getContext('2d');

				var $dashChartBarsData = {
					labels: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'],
					datasets: [{
						label: '注册用户',
						borderWidth: 1,
						borderColor: 'rgba(0,0,0,0)',
						backgroundColor: 'rgba(51,202,185,0.5)',
						hoverBackgroundColor: "rgba(51,202,185,0.7)",
						hoverBorderColor: "rgba(0,0,0,0)",
						data: [2500, 1500, 1200, 3200, 4800, 3500, 1500]
					}]
				};
				var $dashChartLinesData = {
					labels: ['2003', '2004', '2005', '2006', '2007', '2008', '2009', '2010', '2011', '2012', '2013',
						'2014'
					],
					datasets: [{
						label: '交易资金',
						data: [20, 25, 40, 30, 45, 40, 55, 40, 48, 40, 42, 50],
						borderColor: '#358ed7',
						backgroundColor: 'rgba(53, 142, 215, 0.175)',
						borderWidth: 1,
						fill: false,
						lineTension: 0.5
					}]
				};

				new Chart($dashChartBarsCnt, {
					type: 'bar',
					data: $dashChartBarsData
				});

				var myLineChart = new Chart($dashChartLinesCnt, {
					type: 'line',
					data: $dashChartLinesData,
				});
			});
			// li标签点击添加active效果

			$("li").click(function() {
				$(this).siblings('li').removeClass('active'); // 删除其兄弟元素的样式
				$(this).addClass('active'); // 为点击元素添加样式
			});

			function changetop(item) {
				$('#toptext').text(item.children[0].text);
			}
		</script>

	</body>
</html>
